Chris Pollett > Old Classes >
CS174

( Print View )

Student Corner:
  [Grades Sec1]

  [Submit Sec1]

  [Class Sign Up Sec1]

  [
Lecture Notes]
  [Discussion Board]

Course Info:
  [Texts & Links]
  [Topics/Outcomes]
  [Outcomes Matrix]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HWs and Quizzes:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5][Quizzes]

Practice Exams:
  [Mid1]  [Final]

                           












HW#3 --- last modified February 28 2019 22:14:59..

Solution set.

Due date: Oct 28

Files to be submitted:
  Hw3.zip

Purpose: To gain experience extending the functionality of, writing a performance profiler for, and writing tests for an existing software project. To experiment with svn and bug-tracking.

Related Course Outcomes:

LO4 -- Write client-side scripts that validate HTML forms.

LO5 -- Develop and deploy web applications that involve components, web services, and databases.

Specification:

Your starting point for this homework is a genealogy web-site that I developed for personal used in 2008. Here is the Genealogy Web Site-ZIP. Download it and put it in your htdocs directory and look in the config folder to find a readme.txt file with an explanation of how to deploy this site. For this homework, you will code three improvements to this site.

The first improvement I want you to make the web-site is to make adding relationships to a person easier and more fool-proof. Currently, to add a relationship for a person, you click on the "Add a new relationship for this person" link under the View/Edit Details page for that person. This pops up a form with two fields, one to enter the description of the relationship, the other to enter the person ID of the person the relationship is with. This is awkward for the following reasons: (1) you have to know the person ID of the person who you want to make related, (2) some users might enter different names for the same relationship (for instance, son,son of, Son, etc), making it hard to restrict by relationship in the family tree drawing mode, (3) relationships are directed, if you say X is the son of Y, you also have to add separately Y is the father of X. Your job is to make this portion of the site more elegant. I want you to create a new table RelationshipType. This table has columns: id, name, reciprocalID. The first column is the ID of the given relationship, the second colums is the name of the relationship for example, son of, the last column is the id of the relationship that goes the other way or NULL if there isn't any such relationship. For example, if the name was "son of", the recriprocalID might point to a row with the father of relationship type. Put the create statement for this new table in the createDB.sql file in the config folder of the project. Given this table, the web-site should now have a settings link in a noticeable place on the site, clicking on this link should, take you to pages which are controlled by an admin controller. This should be a new file, admin.php, you write in the controllers folder. The settings pages should allow you to create and delete relationship types. When you create a new relationship type, there should be a drop down to select from available reciprocal types. If the user does not set the reciprocal type before clicking a submit button, javascript should be used to warn the user before creating the type. Now on the View/Edit Details page rather than let the person type into a field the relationship type, instead use a drop down that pulls its options from the RelationshipType table. Add a relationship of a given type should automatically add the reciprocal relationship if it exists. To choose the person the relationship is with, I want you to find a better solution that entering an ID, but leave it somewhat up to your imagination. However, realize that the person table might have thousands of rows, so it doesn't make sense to only rely on a drop down.

The second improvement I want you to make is to create debugging/profiling feature for the web-site. You should create a new define in config.php called DEBUG. By default, when DEBUG is 0, the debugging profiling feature is turned off. When the DEBUG constant is greater than zero, when a user browses the site they will see, debugging/ profiling information after the view on the page. The profiling information should be stored in an associative array $profile which is initialized to the empty array before the controller is loaded by index.php. You should write a setter setProfile in datasource_manager.php to allow the $profile to be set of a DatasourceManager class. Similarly write a setter for the Person class. Whenever in the controller we call get instance of the Person class we should also call this setter with the global variable $profile. When DatasourceManager is initialized in index.php, you should also call setProfile($profile). If DEBUG is nonzero, then when execute in a DatasourceManager is called. It takes the time before the query is run, the time after the query is run, and it adds to $profile an association "Query" => array($sql, $endTime-$startTime). You might what to make the execute function of DatasourceManager not abstract to implement this. Instead, it should call a delegate function execSQL which is abstract that actually would call the database. The latter function could then be subclassed to the specific DB. For Person, whenever a method name beginning with "find" is called I want you to add the return result to $profile just before the method ends as an entery "Model Calculated" => $result. Finally, in default_layout.php, just after the view is output, I want you to pretty print all the data you have stored in $profile.

The last improvement I want you to make to the web site is to add some unit tests for the views, controllers, and models on the site. Put these tests in a new folder test which should be a folder immediately under the folder for the whole project. You should also write a new controller file test.php. If someone goes to your site with ?controller=test it should display a page with a link for each unit tests written in the test folder. You should write at least two unit tests. A unit test consists of initialize some variables, loading the php file that is being tested, calling each function in the test file with the test variables, and checking if the result was as expected. Each function test should have a name, you should print out in test passed or test failed for each test.

You are supposed to be managing your code using svn and a bug-tracking tool such as FogBugs. Break the above task into bugs and assign them to your team mates. Before checking in to the repository, make patches, and have another team mate review the patch. When you commit to the repository, use messages of the form: Fixes BugXXXX, r=whoever_did_the_review. Put a file BugTranscript.txt with the text of all the bugs you worked on for the homework in the root folder of your repository. Also list the name and id of all team members in this file!

Point Breakdown

BugTranscript.txt is as described, matches with svn commit logs. 1pt
Improvements to the way Relationship handled, 1pt for adding RelationshipType features as described, 1pt for Javascript checks and adding the drop down to view edit details, 1pt for coming up with a good solution to the relationship ID problem 3pts
Debugger/Profiler - 1pt DEBUG and $profile, layout modified as described, 1pt changes to Person as described, 1pt changed to DatasourceManager as described 3pts
Unit tests 1pt for test.php, 1pt for each unit test 3pts
Total10pts